home *** CD-ROM | disk | FTP | other *** search
- /*
- ### allocate memory dynamically after selecting or loading a new model ###
- */
-
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #include <suntool/panel.h>
-
- void malloc_init()
- {
- int *ivector(),**imatrix();
- double *dvector(),**dmatrix();
- char **svector();
- extern int batch_on,func_on,var_dim,full_dim,func_dim,param_dim,aux_max;
- extern int var_dim_max,func_dim_max,param_dim_max,all_dim_max;
- extern int *aux_on,*aux_win_mode,*aux_rescale,**aux_cur_index;
- extern double *var_i,*var_polar_i,*var_min,*var_max,*var_polar_min,*var_polar_max;
- extern double *v,*t_v,*t_vf,*t_va,*xoffset,*int_yscal,*period_len;
- extern double *win_var_i,*win_var_f,*win_var_i_old;
- extern double *func,*func_i,*func_f,*func_min,*func_max,*func_min_top,*func_max_top;
- extern double *all_min,*all_max,*all_min_top,*all_max_top;
- extern double *param,*param_min,*param_max,*param_min_top,*param_max_top;
- extern double **aux_x_max,**aux_x_min;
- extern char **var_label,**var_polar_label,**func_label,**param_label,**win_var_label,**all_label;
- extern Frame *aux_frame;
- extern Canvas *aux_canvas;
- extern Cursor *aux_cursor;
- extern Panel *aux_panel;
- extern Pixwin **aux_pw;
- extern Panel_item *param_item,*var_i_item,*func_i_item,*func_f_item,*all_min_item,*all_max_item,*int_yscal_item;
- extern Panel_item *aux_quit_item,*aux_copy_item,*aux_win_mode_item,*aux_x_item,*aux_y_item,*aux_x_min_item,*aux_x_max_item,*aux_y_min_item,*aux_y_max_item;
-
- full_dim = (func_on ? var_dim+func_dim : var_dim);
-
- var_i = dvector(0,var_dim -1);
- var_polar_i = dvector(0,var_dim-1);
- var_min = dvector(0,var_dim-1);
- var_max = dvector(0,var_dim-1);
- var_polar_min = dvector(0,var_dim-1);
- var_polar_max = dvector(0,var_dim-1);
-
- win_var_i = dvector(0,var_dim -1);
- win_var_i_old = dvector(0,var_dim -1);
- win_var_f = dvector(0,var_dim -1);
-
- func = dvector(0,func_dim-1);
- func_i = dvector(0,func_dim-1);
- func_f = dvector(0,func_dim-1);
- func_min = dvector(0,func_dim-1);
- func_max = dvector(0,func_dim-1);
-
- /*
- * In order not to waste the memory, free and reallocate memory
- * dynamically when func_on is turned on by event handlers.
- */
- all_min = dvector(0,full_dim+param_dim-1);
- all_max = dvector(0,full_dim+param_dim-1);
- all_min_top = dvector(0,full_dim+param_dim-1);
- all_max_top = dvector(0,full_dim+param_dim-1);
- aux_x_min = dmatrix(0,full_dim+param_dim-1,0,aux_max-1);
- aux_x_max = dmatrix(0,full_dim+param_dim-1,0,aux_max-1);
-
-
- param = dvector(0,param_dim-1);
- param_min = dvector(0,param_dim-1);
- param_max = dvector(0,param_dim-1);
- param_min_top = dvector(0,param_dim-1);
- param_max_top = dvector(0,param_dim-1);
-
- period_len = dvector(0,full_dim+param_dim-1);
-
- v = dvector(0,full_dim-1);
- t_v = dvector(0,full_dim-1);
- t_vf = dvector(0,full_dim-1);
- t_va = dvector(0,full_dim+param_dim-1);
-
- aux_win_mode = ivector(0,aux_max-1);
- aux_on = ivector(0,aux_max-1);
- aux_rescale = ivector(0,aux_max-1);
- aux_cur_index = imatrix(0,aux_max-1,0,1);
-
- all_label = svector(0,all_dim_max-1);
- win_var_label = svector(0,all_dim_max-1);
- param_label = svector(0,param_dim_max-1);
- func_label = svector(0,func_dim_max-1);
- /* THe way it should be */
- /*
- all_label = svector(0,full_dim+param_dim-1);
- win_var_label = svector(0,full_dim+param_dim-1);
- param_label = svector(0,param_dim-1);
- func_label = svector(0,func_dim-1);
- */
-
- var_label = svector(0,var_dim_max -1);
- var_polar_label = svector(0,var_dim_max -1);
-
- int_yscal = dvector(0,var_dim-1);
- xoffset = dvector(0,var_dim-1);
-
- if(!batch_on){
- param_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * param_dim);
- var_i_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * var_dim);
- func_i_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * func_dim);
- func_f_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * func_dim);
- all_min_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * (full_dim+param_dim));
- all_max_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * (full_dim+param_dim));
- int_yscal_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * var_dim);
-
- /* aux windows */
- aux_frame = (Frame *) malloc((unsigned) sizeof(Frame) * aux_max);
- aux_canvas = (Canvas *) malloc((unsigned) sizeof(Canvas) * aux_max);
- aux_cursor = (Cursor *) malloc((unsigned) sizeof(Cursor) * aux_max);
- aux_panel = (Panel *) malloc((unsigned) sizeof(Panel) * aux_max);
- aux_pw = (Pixwin **) malloc((unsigned) sizeof(Pixwin *) * aux_max);
- aux_quit_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_win_mode_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_copy_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_x_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_y_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_x_min_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_x_max_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_y_min_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- aux_y_max_item = (Panel_item *) malloc((unsigned) sizeof(Panel_item) * aux_max);
- }
- (int) default_init();
- }
-